/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Map;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
import org.junit.*;

/**
 *
 * @author Eric-Standard
 */
public class RandomMapGen {

    public RandomMapGen() throws IOException {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }
    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //
    // @Test
    // public void hello() {}

    @Test
    public void randMap() throws IOException {
        File tempFile = File.createTempFile("testMap", ".txt");
        //tempFile.deleteOnExit();
        FileWriter fileWriter = new FileWriter(tempFile);
        int size = 10;
        Random r = new Random();
        fileWriter.write(Integer.toString(size));
        fileWriter.write("\r\n");
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < Map.MAP_WIDTH; j++) {
                int rand = r.nextInt(10) + 10;
                fileWriter.write(Integer.toString(rand));
                fileWriter.write(" ");
            }
            fileWriter.write("\r\n");
        }
        fileWriter.close();
        System.out.println(tempFile.getAbsolutePath());
        Map map = MapLoader.loadMap(tempFile);
        String str = Arrays.toString(map.arr);
        for (int i = 0; i < map.arr.length; i++) {
            str += Arrays.toString(map.arr[i]);
            str += "\n";
        }
        System.out.println(str);
    }
}
